<template>
  <div class="container">
    <!-- 预览dialog区域 -->
    <el-dialog
      append-to-body
      title="题目审核"
      :visible.sync="checkdialog"
      width="50%"
      @closedialog="this.checkdialog = false"
    >
      <el-radio-group v-model="checkradio">
        <el-radio :label="1">通过</el-radio>
        <el-radio :label="2">拒绝</el-radio>
      </el-radio-group>
      <el-input class="input" type="textarea" v-model="areaText"></el-input>
      <el-row class="confirm">
        <el-button class="confirmBtn" @click = "closeCheckDialog">取 消</el-button>
        <el-button class="confirmBtn" type="primary" @click="addcheck"
          >确 认</el-button
        >
      </el-row>
    </el-dialog>
    <!-- 试题审核对话框 -->


    <!-- 题目预览对话框 -->
    <el-dialog
      title="题目审核"
      :visible.sync="questionCheckDialogVisible"
      width="50%"
    >
      <!-- 内容区域 -->
      <span>这是一段信息</span>
      <!-- 底部区域 -->
      <span slot="footer" class="dialog-footer">
        <el-button @click="questionCheckDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="questionCheckDialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>

    <!-- /题目预览对话框 -->
  </div>
</template>

<script>
import { createAPI } from "@/utils/request";
export default {
  props: {
    id: {
      type: Number,
      default:'',
    }
  },
  data() {
    return {
      checkradio: 1,
      areaText: "",
      checkdialog: false,
      questionCheckDialogVisible:false
    }
  },
  methods: {
    // 点击关闭审核弹框
    closeCheckDialog() {
      this.checkdialog = false;
      this.$message.info('取消审核')
    },
    async addcheck () {
      console.log(this.checkradio,this.id,this.areaText.trim(),"1111111111")
      if (this.areaText.trim() === '') {
        this.$message.error('审核意见不能为空')
        this.checkradio = 1
      } else {
      const id = parseInt(this.id)
      const data = {chkState: this.checkradio,chkRemarks: this.areaText.trim(),id: this.id}
      const { data:res } = await createAPI(`/questions/check/${id}`,"post", data)
      console.log(res)
      this.$message.success('操作成功')
      this.checkradio = 1
      this.checkdialog = false;
      }
    }
  },
};
</script>

<style scoped lang="less" scoped>
.input {
  margin-top: 15px;
}
.confirm {
  margin-top: 20px;
  text-align: center;
}
</style>



